package com.zhuiYun.project.api.handworkDiy.mapper;

import com.zhuiYun.project.api.handworkDiy.entity.HandworkDiy;
import com.zhuiYun.project.api.handworkDiy.model.HandworkDiyModel;
import com.zhuiYun.project.common.mapper.BaseMapper;
import com.zhuiYun.project.util.pageUtil.PageRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface handworkMapper  extends BaseMapper<HandworkDiy> {




    /**
     * @Author 小江
     * @Description //TODO  订单全查（模糊查）
     * @Date 14:49 2023/4/7
     **/

    @Select("<script>SELECT a.*,b.type_sname AS typeB FROM handwork_diy a LEFT JOIN commodity_small_type b ON a.diy_classification_id = b.id" +
            " where a.del_flag = 0 " +
            " <when test = 'diyName != &quot;&quot; and diyName != null'>" +
            "and a.diyName like '%${diyName}%'</when>" +
            "</script>")
    @Results({
            @Result(property="diyName",column="diy_name"),
            @Result(property="diyPrice",column="diy_price"),
            @Result(property="diyFavorablePrice",column="diy_favorable_price"),
            @Result(property="diyVipPrice",column="diy_vip_price"),
            @Result(property="diyImageId",column="diy_image_id"),
            @Result(property="diyDetailsImageId",column="diy_details_image_id"),
            @Result(property="diy_grade",column="diyGrade"),
            @Result(property="diyClassificationId",column="diy_classification_id"),
            @Result(property="recommendedScenarios",column="recommended_scenarios"),
            @Result(property="recommendedPeopleNumber",column="recommended_people_number"),
            @Result(property="detailsOfPurchaseInstructions",column="details_of_purchase_instructions"),
            @Result(property="salesVolume",column="sales_volume"),
            @Result(property="isOffer",column="is_offer"),
            @Result(property="isCharacteristic",column="is_characteristic"),
    })
    List<HandworkDiyModel> diysList(String diyName, PageRequest pageResult);



    /**
     * @Author 小江
     * @Description //TODO 查询删除订单信息
     * @Date 9:43 2023/4/18
     **/
    @Select("<script>SELECT a.*,b.type_sname AS typeB FROM handwork_diy a LEFT JOIN commodity_small_type b ON a.diy_classification_id = b.id" +
            " where a.del_flag = 1 " +
            " <when test = 'diyName != &quot;&quot; and diyName != null'>" +
            "and a.diyName like '%${diyName}%'</when>" +
            "</script>")
    @Results({
            @Result(property="diyName",column="diy_name"),
            @Result(property="diyPrice",column="diy_price"),
            @Result(property="diyFavorablePrice",column="diy_favorable_price"),
            @Result(property="diyVipPrice",column="diy_vip_price"),
            @Result(property="diyImageId",column="diy_image_id"),
            @Result(property="diyDetailsImageId",column="diy_details_image_id"),
            @Result(property="diy_grade",column="diyGrade"),
            @Result(property="diyClassificationId",column="diy_classification_id"),
            @Result(property="recommendedScenarios",column="recommended_scenarios"),
            @Result(property="recommendedPeopleNumber",column="recommended_people_number"),
            @Result(property="detailsOfPurchaseInstructions",column="details_of_purchase_instructions"),
            @Result(property="salesVolume",column="sales_volume"),
            @Result(property="isOffer",column="is_offer"),
            @Result(property="isCharacteristic",column="is_characteristic"),
    })
    List<HandworkDiyModel> regretDiy(String diyName, PageRequest pageResult);

    /**
     * @Author 小江
     * @Description //TODO 订单
     * @Date 9:43 2023/4/18
     **/
    @Select("SELECT  id,diy_name,1 diycomm FROM handwork_diy Union all SELECT id,commodity_name,2 diycomm FROM commodity")
    @Results({
            @Result(property="diyName",column="diy_name"),
            @Result(property="diyPrice",column="diy_price"),
            @Result(property="diyFavorablePrice",column="diy_favorable_price"),
            @Result(property="diyVipPrice",column="diy_vip_price"),
            @Result(property="diyImageId",column="diy_image_id"),
            @Result(property="diyDetailsImageId",column="diy_details_image_id"),
            @Result(property="diy_grade",column="diyGrade"),
            @Result(property="diyClassificationId",column="diy_classification_id"),
            @Result(property="recommendedScenarios",column="recommended_scenarios"),
            @Result(property="recommendedPeopleNumber",column="recommended_people_number"),
            @Result(property="detailsOfPurchaseInstructions",column="details_of_purchase_instructions"),
            @Result(property="salesVolume",column="sales_volume"),
            @Result(property="isOffer",column="is_offer"),
            @Result(property="isCharacteristic",column="is_characteristic"),
    })
    List<HandworkDiyModel> commanddiylist(HandworkDiyModel handworkDiyModel);


    
    /**
     * @Author 小江
     * @Description //TODO 查询回收站的diy商品
     * @Date 11:29 2023/4/18
     **/
    @Select("<script>SELECT a.*,b.type_sname AS typeB FROM handwork_diy a LEFT JOIN commodity_small_type b ON a.diy_classification_id = b.id" +
            " where a.del_flag = 2" +
            " <when test = 'diyName != &quot;&quot; and diyName != null'>" +
            "and a.diyName like '%${diyName}%'</when>" +
            "</script>")
    @Results({
            @Result(property="diyName",column="diy_name"),
            @Result(property="diyPrice",column="diy_price"),
            @Result(property="diyFavorablePrice",column="diy_favorable_price"),
            @Result(property="diyVipPrice",column="diy_vip_price"),
            @Result(property="diyImageId",column="diy_image_id"),
            @Result(property="diyDetailsImageId",column="diy_details_image_id"),
            @Result(property="diy_grade",column="diyGrade"),
            @Result(property="diyClassificationId",column="diy_classification_id"),
            @Result(property="recommendedScenarios",column="recommended_scenarios"),
            @Result(property="recommendedPeopleNumber",column="recommended_people_number"),
            @Result(property="detailsOfPurchaseInstructions",column="details_of_purchase_instructions"),
            @Result(property="salesVolume",column="sales_volume"),
            @Result(property="isOffer",column="is_offer"),
            @Result(property="isCharacteristic",column="is_characteristic"),
    })
    List<HandworkDiyModel> recycleDiy(String diyName, PageRequest pageResult);
}


